import service from "@/api/index.js";

const scenicSpotApi = {
    //添加
    insert(scenicSpot){
        return service.post("/scenicSpot",scenicSpot);
    },
    //删除
    delete(id){
        return service.delete(`/scenicSpot/${id}`);
    },
    //修改
    update(scenicSpot){
        console.log(scenicSpot.addr);
        return service.put("/scenicSpot",scenicSpot);
    },
    //分页搜索
    selectByPage(condition, pageNum, pageSize){
        condition.pageNum = pageNum;
        condition.pageSize = pageSize;
        return service.get("/scenicSpot",{
            params: condition
        });
    },
    //分页搜索 注意id既可以是父分类的id也可以是子分类的id
    selectByPage1(condition, pageNum, pageSize){
        condition.pageNum = pageNum;
        condition.pageSize = pageSize;
        return service.get("/scenicSpot/search",{
            params: condition
        });
    },
    // 搜索排名前4的景区
    selectByRank(){
        return service.get("/scenicSpot/rank");
    },
    //根据id搜索
    selectById(id){
        return service.get(`/scenicSpot/${id}`);
    },
    scenicSpotTop5(){
        return service.get("/scenicSpot/scenicSpotTop5")
    }
}

export default scenicSpotApi;